package easymall.clients;

import easymall.config.MultipartSupportConfig;
import easymall.po.Products;
import easymall.pojo.MyProducts;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@FeignClient(value="productservice",configuration = MultipartSupportConfig.class)
public interface ProductsService {

    @PostMapping("/prodlist")
    public List<Products> prodlist(@RequestBody Map<String, Object> map);

    @GetMapping("/oneProduct")
    public Products oneProduct(@RequestParam String pid);

    @GetMapping("/proclass")
    public List<Products> proclass(@RequestParam Integer category);

    @PostMapping(value = "/save",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String save(@RequestPart("file")  MyProducts myproducts);

    //分页相关
    @GetMapping("/getProductsByPage")
    public List<Products> getProductsByPage(@RequestParam Integer page);

    @GetMapping("/getTotalPageByProducts")
    public int getTotalPageByProducts();

    //商品相关
    @PostMapping(value="/updatePruduct",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public String updatePruduct(@RequestPart("file") MyProducts myproducts, @RequestParam String id);

    //
    @GetMapping("/delProduct")
    public int delProduct(@RequestParam String id);
}
